#ifndef QTEXEDIT_H
#define QTEXEDIT_H

#include <QPlainTextEdit>
#include <QListWidget>
#include <3rd-party/hunspell/hunspell.hxx>

class QTeXEdit;

class Completor:public QListWidget{
    Q_OBJECT


public:
    QTeXEdit* theEdit;
    explicit Completor(QWidget *parent = 0);
signals:
    void submit(QListWidgetItem*);
protected:
    virtual void keyPressEvent ( QKeyEvent * e );
    virtual void keyReleaseEvent ( QKeyEvent * e );
};

class QTeXEdit : public QPlainTextEdit
{
    Q_OBJECT

    Completor* cmp;
    Hunspell* sChecker;
public:
    explicit QTeXEdit(QWidget *parent = 0);
    void setCompleter(Completor *w);

    void applySpellDict(QString dicName, QString path="");
    
signals:
    void askToComplete(QString);
    
public slots:
    void activateItem(QListWidgetItem* it);

protected:
    virtual void keyPressEvent ( QKeyEvent * e );
    virtual void keyReleaseEvent ( QKeyEvent * e );
    virtual void inputMethodEvent ( QInputMethodEvent * e );
    virtual void mousePressEvent(QMouseEvent *e);
    
};

#endif // QTEXEDIT_H
